using System.Collections.Generic;

namespace GameFramework.Reference
{
    /// <summary>
    /// 兼容客户端接口
    /// </summary>
    public abstract class AReference
    {
        public abstract void OnRecycle();
        
        public void Recycle()
        {
            OnRecycle();
        }
    }

    public static class ReferenceExtensions
    {
        /// <summary>
        /// 回收实例
        /// </summary>
        public static void Recycle(this AReference reference)
        {
            // nothing to do
        }
        
        /// <summary>
        /// 回收实例
        /// </summary>
        public static void Recycle(this Message reference)
        {
            // nothing to do
        }
        
        /// <summary>
        /// 回收容器中的实例
        /// </summary>
        public static void RecycleItems<T>(this ICollection<T> collection) where T : AReference
        {
            // nothing to do
        }
        
        /// <summary>
        /// 回收容器中的实例
        /// </summary>
        public static void RecycleItems<TK, T>(this IDictionary<TK, T> collection) where T : AReference
        {
            // nothing to do
        }
    }
}